﻿using ESRI.ArcGIS.ADF.BaseClasses;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using PlanningGIS.Framework;

namespace PlanningGIS.File
{
    /// <summary>
    /// 切换并激活地图
    /// </summary>
    public class ActiveMap : BaseCommand
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        public ActiveMap()
        {
            base.m_caption = "切换地图";
            base.m_toolTip = base.Caption;
        }

        /// <summary>
        /// 应用程序
        /// </summary>
        IApplication m_Application = null;

        /// <summary>
        /// 创建按钮
        /// </summary>
        /// <param name="hook"></param>
        public override void OnCreate(object hook)
        {
            if (m_Application == null)
            {
                m_Application = hook as IApplication;
            }
        }

        /// <summary>
        /// 点击按钮，加载数据
        /// </summary>
        public override void OnClick()
        {
            //(m_Application.Document as IMxDocument)
            FrmMaps frm = new FrmMaps();
            frm.AddMaps((m_Application.Document as MxDocumentClass).MapDocument);
            if (frm.ShowDialog() != System.Windows.Forms.DialogResult.OK) return; ;
            (m_Application as ApplicationClass).ChangeMap(frm.FocusMap.Name);
        }

        ///// <summary>
        ///// 图标
        ///// </summary>
        //public override int Bitmap
        //{
        //    get
        //    {
        //        string bitmapResourceName = this.GetType().Namespace + ".Res." + this.GetType().Name + ".JPG";
        //        return new Bitmap(GetType().Assembly.GetManifestResourceStream(bitmapResourceName)).GetHbitmap().ToInt32();
        //    }
        //}

        /// <summary>
        /// 是否可用
        /// </summary>
        public override bool Enabled
        {
            get
            {
                if (m_Application == null) return false;
                return true;
            }
        }
    }
}
